<!--
 * @Author: Bobby
 * @Date: 2021-12-30 10:01:42
 * @LastEditTime: 2022-02-15 17:59:22
 * @LastEditors: Bobby
 * @Description:
 * @FilePath: \wms-v2\src\ve\elements\other\uiLink\uiLink.vue
 * CIMC-V2
-->
<template>
  <el-progress :color="info.extension.color.value" :percentage="model" />
</template>
<script>
  import { defineComponent } from 'vue'
  import { UiMixin } from '@ve/mixin'
  import cloneDeep from 'lodash/cloneDeep'
  import isEmpty from 'lodash/isEmpty'
  export default defineComponent({
    name: 'UiProgress',
    components: {},
    mixins: [UiMixin],
    data() {
      return {
        model: '',
      }
    },

    created() {
      // console.log('进度条a', this.info)
      this.model = cloneDeep(this.info.extension.defaultValue.value)
    },
    methods: {
      dataSourceChange(newval) {
        console.log('进度条', newval)
        let _data = cloneDeep(newval)
        if (!isEmpty(newval) && newval.data && newval['data'].length > 0) {
          //key
          if (this.info.dataSourceBind.getDataKey && this.info.dataSourceBind.getDataKey.value) {
            _data = _data[this.info.dataSourceBind.getDataKey.value]
          }
          //index
          if (this.info.dataSourceBind.getArrayIndex && this.info.dataSourceBind.getArrayIndex.value != 'all') {
            _data = _data[this.info.dataSourceBind.getArrayIndex.value]
          }

          this.model = _data[this.info.extension.model.value]
        } else {
          if (_data[this.info.extension.model.value]) {
            this.model = _data[this.info.extension.model.value]
          }
        }
      },
    },
  })
</script>
